package com.example.wuqujingdianphone.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.wuqujingdianphone.R;
import com.example.wuqujingdianphone.api.ApiConfig;
import com.example.wuqujingdianphone.bean.BookListBean2;
import com.example.wuqujingdianphone.bean.BrowsingHistoryBean;
import com.example.wuqujingdianphone.utils.TimeUtils;

import java.util.List;

/**
 * Created by yuanpk on 2018/4/9.
 */

public class BrowsingHistoryAdapter extends BaseQuickAdapter<BrowsingHistoryBean, BaseViewHolder> {

    private Context mContext;

    public BrowsingHistoryAdapter(Context context, @Nullable List<BrowsingHistoryBean> data) {
        super(R.layout.item_browshinghistory, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, BrowsingHistoryBean item) {


      /*  Glide.with(mContext)
                .load(ApiConfig.APP_URL + item.spic)
                .error(R.drawable.icon_book_cover_defalt)
                .placeholder(R.drawable.icon_book_cover_defalt)
                .centerCrop()
                .into((ImageView) helper.getView(R.id.image));*/

        helper.setText(R.id.book_name, item.bname)
                .setText(R.id.type, "" + item.fname)//类型：
                .setText(R.id.time, "浏览时间：" + TimeUtils.getTimePickerView(item.add_time == null ? 0L : Long.parseLong(item.add_time)))
        ;

        if (TextUtils.isEmpty(item.jianjie)) {
            helper.setText(R.id.jianjie, "简介：暂无简介");
        } else {
            helper.setText(R.id.jianjie, "简介：" + item.jianjie);
        }

    }
}
